#pragma once
#include <memory>
#include "boost/beast.hpp"
#include <unordered_map>

namespace beast = boost::beast;
namespace http = beast::http;
namespace net = boost::asio;
using tcp = net::ip::tcp;

class HttpConnection:public std::enable_shared_from_this<HttpConnection>
{
    friend class LogicSystem;
public:
    HttpConnection(boost::asio::io_context& io_context);
    void Start();
    tcp::socket& GetSocket(){return socket_;}



private:
    void CheckDeadLine();
    void HandleReq();
    void WriteResponse();
    void PreParseGetParam();

private:
    tcp::socket socket_;
    //设置定时器
    boost::asio::steady_timer deadline_;
    beast::flat_buffer buffer_{8192};
    //http请求
    http::request<http::dynamic_body> request_;
    //http响应
    http::response<http::dynamic_body> response_;
    std::unordered_map<std::string,std::string> get_params_;
    std::string get_url_;
};
